<?php

// 本类由系统自动生成，仅供测试用途
class ModifygoodsAction extends Action {

    public function index() {
        $goods = M('goods');
        $goodsid = $_GET['goodsid'];
        $condition['id'] = $goodsid;
        $list = $goods->where($condition)->find();
        $this->assign('list', $list);
        $this->display();
    }

    public function update() {

        $goods = M('goods');
        if ($_POST['goodsname'] == NULL) {
            $this->error('请填写货物名称！');
        }
        if ($_POST['goodsprice'] == NULL) {
            $this->error('请填写货物价格！');
        }
        //var_dump($_POST);
        $data['id'] = $_POST['goodsid'];
        $data['goodsname'] = $_POST['goodsname'];
        $data['goodsprice'] = $_POST['goodsprice'];
        $data['remark'] = $_POST['goodsremark'];
        if ($goods->save($data)) {
            $this->success('信息修改成功！');
        } else {
            $this->error('信息修改失败！');
        }
    }

}